package com.deer.wms.base.system.service.zh.impl;

import com.deer.wms.base.system.dao.task.BillInTaskInfoMapper;
import com.deer.wms.base.system.dao.zh.ShelfPlanMapper;
import com.deer.wms.base.system.model.zh.ShelfPlan;
import com.deer.wms.base.system.service.zh.ShelfPlanService;
import com.deer.wms.common.core.service.AbstractService;
import com.deer.wms.common.core.text.Convert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 李帅辰
 * @date 2021/5/26 14:48
 */
@Service
public class ShelfPlanServiceImpl extends AbstractService<ShelfPlan,Integer> implements ShelfPlanService {

    @Autowired
    private ShelfPlanMapper shelfPlanMapper;

    @Autowired
    private BillInTaskInfoMapper billInTaskInfoMapper;

    @Override
    public ShelfPlan findShelfPlanById(Integer id) {
        return shelfPlanMapper.findShelfPlanById(id);
    }

    @Override
    public ShelfPlan findShelfPlanByshelfPlan(ShelfPlan shelfPlan) {
        return shelfPlanMapper.findShelfPlanByshelfPlan(shelfPlan);
    }

    @Override
    public List<ShelfPlan> findShelfPlanList(ShelfPlan shelfPlan) {
        return shelfPlanMapper.findShelfPlanList(shelfPlan);
    }

    @Override
    public int delectShelfPlanById(Integer id) {
        return shelfPlanMapper.delectShelfPlanById(id);
    }

    @Override
    public int delectShelfPlanByIds(String ids) {
        return shelfPlanMapper.delectShelfPlanByIds(Convert.toStrArray(ids));
    }

    @Override
    public int updateShelfPlan(ShelfPlan shelfPlan) {
        return shelfPlanMapper.updateShelfPlan(shelfPlan);
    }

    @Override
    public int saveShelfPlan(ShelfPlan shelfPlan) {
        return shelfPlanMapper.saveShelfPlan(shelfPlan);
    }

    @Override
    public List<ShelfPlan> findQuantityAndShelf(ShelfPlan shelfPlan) {
        List<ShelfPlan> quantityAndShelf = shelfPlanMapper.findQuantityAndShelf(shelfPlan);
        return quantityAndShelf;
    }

    @Override
    public boolean getCount(ShelfPlan shelfPlan) {
        List<ShelfPlan> count = shelfPlanMapper.getCount(shelfPlan);
        for (ShelfPlan plan : count) {
            if (null!=plan.getQuantity() || 0!=plan.getQuantity()){
                return true;
            }
        }
        return false;
    }
}
